/**
 * 系统设置 新增病例
 */
<template>
  <div>
    <el-row>
      <el-col :span="24">
        <h3>患者信息</h3>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24">
        <!-- 患者信息 -->
                <el-form :inline="true" :model="formInline" class="user-search">
                  <el-form-item label="患者姓名">
                    <el-input :disabled="true" size="small" v-model="formInline.name" ></el-input>
                  </el-form-item>
                  <el-form-item label="患者年龄">
                    <el-input :disabled="true" size="small" v-model="formInline.age" ></el-input>
                  </el-form-item>
                  <el-form-item label="患者性别">
                    <el-input :disabled="true" size="small" v-model="formInline.sex" ></el-input>
                  </el-form-item>

                </el-form>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24">
        <h3>体格信息</h3>
      </el-col>
    </el-row>
    <el-row :gutter="20">
      <el-col :span="6">
        <template >体温：</template>
          <el-input-number :min="0" :max="50" v-model="bodyTemperature">
          </el-input-number>
        <template >℃</template>
      </el-col>
      <el-col :span="6">
          <template >呼吸：</template>
        <el-input-number :min="0" :max="100" v-model="breathe">
        </el-input-number>
          <template >次/分</template>
      </el-col>
      <el-col :span="6">
          <template >脉搏：</template>
        <el-input-number :min="0" :max="200" v-model="pulse">
        </el-input-number>
          <template >次/分</template>
      </el-col>
      <el-col :span="6">
          <template >血压：</template>
        <el-input-number :min="0" :max="300" v-model="bloodPressure">
        </el-input-number>
          <template >mmHg</template>
      </el-col>      
    </el-row>
    <el-row :gutter="20">
      <el-col :span="6">
          <template >身高：</template>
        <el-input-number :min="10" :max="300" v-model="height">
        </el-input-number>
          <template >cm</template>
      </el-col>
      <el-col :span="6">
          <template >体重：</template>
        <el-input-number :min="0" :max="1000" v-model="weight">
        </el-input-number>
          <template >kg</template>
      </el-col>
      <el-col :span="6">
          <template >血糖：</template>
        <el-input-number :min="0" :max="500" v-model="bloodGlucose">
        </el-input-number>
          <template >mmol/L</template>
      </el-col>
      <el-col :span="6">
          <template >血脂：</template>
        <el-input-number :min="0" :max="500" v-model="bloodFat">
        </el-input-number>
          <template >mmol/L</template>
      </el-col>      
    </el-row>
    <el-row>
      <el-col :span="24">
        <h3>病例信息</h3>
      </el-col>
    </el-row>
    <el-row :gutter="20">
      <el-col :span="12">
        发病日期：
        <div class="block">
          <el-date-picker
            style="width:100%"
            v-model="accidentDate"
            type="date"
            placeholder="选择日期">
          </el-date-picker>
        </div>
      </el-col> 
      <el-col :span="12">
        主诉：
        <el-input v-model="symptom">
        </el-input>
      </el-col>
    </el-row>
    <el-row :gutter="20">
      <el-col :span="12">
        诊断：
        <el-input v-model="diagnosis">
        </el-input>
      </el-col> 
      <el-col :span="12">
        医嘱：
        <el-input v-model="doctorAdvice">
        </el-input>
      </el-col>
    </el-row>
    <el-row :gutter="20">
      <el-col :span="12">
        现病史：
        <el-input
          type="textarea"
          :rows="2"
          v-model="presentIllnessHistory">
        </el-input>
      </el-col> 
      <el-col :span="12">
        既往史：
        <el-input
          type="textarea"
          :rows="2"
          v-model="anamnesis">
        </el-input>
      </el-col>
    </el-row>
    <el-row :gutter="20">
      <el-col :span="12">
        过敏史：
        <el-input
          type="textarea"
          :rows="2"
          v-model="allergy">
        </el-input>
      </el-col> 
      <el-col :span="12">
        个人史：
        <el-input
          type="textarea"
          :rows="2"
          v-model="personalHistory">
        </el-input>
      </el-col>
    </el-row>
    <el-row :gutter="20">
      <el-col :span="12">
        家族史：
        <el-input
          type="textarea"
          :rows="2"
          v-model="familyHistory">
        </el-input>
      </el-col> 
      <el-col :span="12">
        辅助检查：
        <el-input
          type="textarea"
          :rows="2"
          v-model="examination">
        </el-input>
      </el-col>
    </el-row>
    <el-row :gutter="20">
      <el-col :span="12">
        治疗意见：
        <el-input
          type="textarea"
          :rows="2"
          v-model="cure">
        </el-input>
      </el-col> 
      <el-col :span="12">
        备注：
        <el-input
          type="textarea"
          :rows="2"
          v-model="remark">
        </el-input>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24">
        <el-button type="primary" round @click="saveCase">去开处方</el-button>
      </el-col>
    </el-row>
  </div>
</template>


<script>
import axios from 'axios'


export default {
  data() {
    return {
      
      bodyTemperature:'',
      breathe:'',
      pulse:'',
      bloodPressure:'',
      bloodGlucose:'',
      bloodFat:'',
      height:'',
      weight:'',
      accidentDate:null,
      symptom:'',
      presentIllnessHistory:'',
      anamnesis:'',
      allergy:'',
      personalHistory:'',
      familyHistory:'',
      examination:'',
      diagnosis:'',
      cure:'',
      doctorAdvice:'',
      remark:'',
      // 患者信息
      formInline:{
        name:'',
        age:'',
        sex:''
      }
    }
  },
    created() {

    this.showPatientInfo();
    
  },
  methods:{
        // 获取患者信息
    showPatientInfo(){
      this.formInline.name=this.$route.query.patientName;
      this.formInline.age=this.$route.query.patientAge;
      this.formInline.sex=this.$route.query.patientSex;
      console.log("******",this.$route.query)
    },

    saveCase(){
        axios.post('/api/register/updateCase',{
          "id":this.$route.query.registerId,
          "bodyTemperature":this.bodyTemperature,
          "breathe":this.breathe,
          "pulse":this.pulse,
          "bloodPressure":this.bloodPressure,
          "bloodGlucose":this.bloodGlucose,
          "bloodFat":this.bloodFat,
          "height":this.height,
          "weight":this.weight,
          "accidentDate":this.accidentDate,
          "symptom":this.symptom,
          "presentIllnessHistory":this.presentIllnessHistory,
          "anamnesis":this.anamnesis,
          "allergy":this.allergy,
          "personalHistory":this.personalHistory,
          "familyHistory":this.familyHistory,
          "examination":this.examination,
          "diagnosis":this.diagnosis,
          "cure":this.cure,
          "doctorAdvice":this.doctorAdvice,
          "remark":this.remark,
          
        })
        .then(res => {
              
              if (res.data.code==200) {
                
                this.$message({
                  type: 'success',
                  message: '保存成功！'
                })

        this.$emit("callFather","second");

              } else {
                this.$message({
                  type: 'info',
                  message: res.data.message
                })
              }
            })
            .catch(err => {
              this.editFormVisible = false
              this.loading = false
              this.$message.error('保存失败，请稍后再试！')
            })
    }
  }
}
</script>

<style scoped>
  .el-row {
    margin-bottom: 20px;
    &:last-child {
      margin-bottom: 0;
    }
  }
  .el-col {
    border-radius: 4px;
  }
  .bg-purple-dark {
    background: #99a9bf;
  }
  .bg-purple {
    background: #d3dce6;
  }
  .bg-purple-light {
    background: #e5e9f2;
  }
  .grid-content {
    border-radius: 4px;
    min-height: 36px;
  }
  .row-bg {
    padding: 10px 0;
    background-color: #f9fafc;
  }
</style>